package com.psp.web.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.psp.web.controller.res.bean.RServiceBean;
import com.psp.web.model.ServiceBean;
import com.psp.web.persist.dao.ServiceDao;
import com.psp.web.service.ServiceService;

@Service
public class ServiceServiceImpl implements ServiceService {
	@Autowired
	ServiceDao serviceImpl;

	@Override
	public List<RServiceBean> getServiceList(int page, int limit) {
		int start = page * limit;

		List<RServiceBean> data = new ArrayList<>();
		List<ServiceBean> services = serviceImpl.selectServiceList(start, limit);

		/**
		 * 服务列表
		 */
		for (ServiceBean s : services) {
			RServiceBean rs = new RServiceBean();
			rs.setSid(s.getSid());
			rs.setCustomer(s.getCustomer());
			rs.setNumber(s.getNumber());
			rs.setPrice(s.getPrice());
			rs.setProduct(s.getProduct());
			rs.setServiceDate(s.getServiceDate());
			rs.setServiceProvider(s.getServiceProvider());
			rs.setContractNo(s.getContractNo());
			rs.setPhone(s.getPhone());
			rs.setUsername(s.getUsername());
			data.add(rs);
		}
		return data;
	}

	@Override
	public int getTotalCount() {
		return serviceImpl.selectTotalCount();
	}

}
